#include "seam.h"

Seam::Seam(int nbPoints)
{
    sumEnergy = 0;
    points = new QPoint*[nbPoints];
    for(int i = 0; i < nbPoints; i++){
        points[i] = NULL;
    }
    numEndElement = 0;
    this->nbPoints = nbPoints;
}

Seam::~Seam(){
    //cout << "in delete seam" << endl;
    //cout << "(points != NULL) " << (points != NULL) << endl;
    if(points != NULL){
        for(int i = 0; i < nbPoints; i++){
      //      cout << "for point " << i << endl;
            if(points[i] != NULL){
                delete (points[i]);
            }else{
        //        cout << "points[i]  == NULL" << endl;
            }
        }
        delete points;
    }
    //cout << "end delete seam" << endl;
}


int Seam::getNbPoints(){
    return nbPoints;
}

int Seam::getSumEnergy(){
    return sumEnergy;
}

void Seam::setSumEnergy(int sumEnergy){
    this->sumEnergy = sumEnergy;
}

void Seam::addPoint(int x, int y){
    points[numEndElement] = new QPoint(x, y);
    numEndElement++;
}
QPoint* Seam::getPoint(int numPoint){
    return points[numPoint];
}

bool Seam::operator< (const Seam & seam) const {
    return (sumEnergy < seam.sumEnergy);
}

void Seam::initValue(int value){
    for(int i = 0; i < nbPoints; i++){
        addPoint(value, value);
    }
}
